#include "bossplay.h"

BossPlay::BossPlay(QWidget *parent) : QMainWindow(parent)
{
    //设置窗口
    //固定尺寸
    this->setFixedSize(mainSceneWidth,mainSceneHeight);
    //标题
    this->setWindowTitle(mainSceneName);
    //图标
    this->setWindowIcon(QIcon(":/res/Coin0001.png"));

    //创建菜单
    QMenuBar * bar = menuBar();
    this->setMenuBar(bar);
    QMenu* startMenu = bar->addMenu("开始");
    QAction * quitAction = startMenu->addAction("退出");
    connect(quitAction,&QAction::triggered,[=](){
        this->close();
    });

    //返回按钮
    PushButton_01 * back =new PushButton_01(":/res/BackButton.png",":/res/BackButtonSelected.png");
    back->setParent(this);
    back->move(this->width() - back->width(),this->height() - back->height());
    connect(back,&PushButton_01::clicked,[=](){
        QTimer::singleShot(500,this,[=](){
            this->hide();
            emit this->BossSceneBack();
        });
    });
    //作弊按钮1
    PushButton_01 * chick1 =new PushButton_01(":/res/zyqg.png",":/res/zyqg.png");
    chick1->setParent(this);
    chick1->move(this->width() - chick1->width()-100,this->height() - chick1->height()-20);
    connect(chick1,&PushButton_01::clicked,[=](){
        if(this->money<10)
        {
            QMessageBox msgbox;
            msgbox.setText("你没钱咯");
            msgbox.exec();
        }
        else
        {
            current = 1;
        }

    });
    //当前1
    QLabel * mlabel1 = new QLabel;
    mlabel1->setParent(this);
    QFont mfont1;
    mfont1.setFamily("华文新魏");
    mfont1.setPointSize(8);
    mlabel1->setFont(mfont1);
    QString mstr1 = QString("使用次数: %1").arg(i1);
    mlabel1->setText(mstr1);
    mlabel1->setGeometry(QRect(this->width() - chick1->width()-100,this->height() - chick1->height(), this->width(),50 ));
    mlabel1->setAttribute(Qt::WA_TransparentForMouseEvents);

    //作弊按钮2
    PushButton_01 * chick2 =new PushButton_01(":/res/hybh.png",":/res/hybh.png");
    chick2->setParent(this);
    chick2->move(this->width() - chick2->width()-200,this->height() - chick2->height()-20);
    connect(chick2,&PushButton_01::clicked,[=](){
        if(this->money<10)
        {
            QMessageBox msgbox;
            msgbox.setText("你没钱咯");
            msgbox.exec();
        }
        else
        {
            current = 2;
        }
    });
    //当前2
    QLabel * mlabel2 = new QLabel;
    mlabel2->setParent(this);
    QFont mfont2;
    mfont2.setFamily("华文新魏");
    mfont2.setPointSize(8);
    mlabel2->setFont(mfont2);
    QString mstr2 = QString("使用次数: %1").arg(i2);
    mlabel2->setText(mstr2);
    mlabel2->setGeometry(QRect(this->width() - chick2->width()-200,this->height() - chick2->height(), this->width(),50 ));
    mlabel2->setAttribute(Qt::WA_TransparentForMouseEvents);

    //作弊按钮3
    PushButton_01 * chick3 =new PushButton_01(":/res/qtsh.png",":/res/qtsh.png");
    chick3->setParent(this);
    chick3->move(this->width() - chick3->width()-300,this->height() - chick3->height()-20);
    connect(chick3,&PushButton_01::clicked,[=](){
        if(this->money<10)
        {
            QMessageBox msgbox;
            msgbox.setText("你没钱咯");
            msgbox.exec();
        }
        else
        {
            current = 3;
        }
    });
    //当前3
    QLabel * mlabel3 = new QLabel;
    mlabel3->setParent(this);
    QFont mfont3;
    mfont3.setFamily("华文新魏");
    mfont3.setPointSize(8);
    mlabel3->setFont(mfont3);
    QString mstr3 = QString("使用次数: %1").arg(i3);
    mlabel3->setText(mstr3);
    mlabel3->setGeometry(QRect(this->width() - chick3->width()-300,this->height() - chick3->height(), this->width(),50 ));
    mlabel3->setAttribute(Qt::WA_TransparentForMouseEvents);

    //作弊按钮4
    PushButton_01 * chick4 =new PushButton_01(":/res/lrfc.png",":/res/lrfc.png");
    chick4->setParent(this);
    chick4->move(this->width() - chick4->width()-400,this->height() - chick4->height()-20);
    connect(chick4,&PushButton_01::clicked,[=](){
        if(this->money<10)
        {
            QMessageBox msgbox;
            msgbox.setText("你没钱咯");
            msgbox.exec();
        }
        else
        {
            current = 4;
        }
    });
    //当前4
    QLabel * mlabel4 = new QLabel;
    mlabel4->setParent(this);
    QFont mfont4;
    mfont4.setFamily("华文新魏");
    mfont4.setPointSize(8);
    mlabel4->setFont(mfont4);
    QString mstr4 = QString("使用次数: %1").arg(i4);
    mlabel4->setText(mstr4);
    mlabel4->setGeometry(QRect(this->width() - chick4->width()-400,this->height() - chick4->height(), this->width(),50 ));
    mlabel4->setAttribute(Qt::WA_TransparentForMouseEvents);

    //当前money
    QLabel * mlabel = new QLabel;
    mlabel->setParent(this);
    QFont mfont;
    mfont.setFamily("华文新魏");
    mfont.setPointSize(20);
    mlabel->setFont(mfont);
    QString mstr = QString("money: %1").arg(this->money);
    mlabel->setText(mstr);
    mlabel->setGeometry(QRect(700,this->height() - 100, this->width(),50 ));
    mlabel->setAttribute(Qt::WA_TransparentForMouseEvents);

    //赚金币
    PushButton_01 * chick5 =new PushButton_01(":/res/zzgd.png",":/res/zzgd.png");
    chick5->setParent(this);
    chick5->move(this->width() - chick5->width()-500,this->height() - chick5->height());
    connect(chick5,&PushButton_01::clicked,[=](){
        this->hide();
        PushButton_01 * earnm =new PushButton_01(":/res/dzmy.jpg","",1);
        earnm->setParent(this->earn);
        earnm->move(0,0);
        this->earn->show();
        connect(earnm,&PushButton_01::clicked,[=](){
            money=money+10;
            connect(this->earn,&EarnMoney::EarnSceneBack,[=](){
                this->show();
                this->earn->hide();
                QString mstr = QString("money: %1").arg(this->money);
                mlabel->setText(mstr);
                mlabel->setGeometry(QRect(700,this->height() - 100, this->width(),50 ));
                mlabel->setAttribute(Qt::WA_TransparentForMouseEvents);
            });
        });
    });

    //当前关卡标题
    QLabel * label = new QLabel;
    label->setParent(this);
    QFont font;
    font.setFamily("华文新魏");
    font.setPointSize(20);
    label->setFont(font);
    QString str = QString("Level:Unbelievable ");
    label->setText(str);
    label->setGeometry(QRect(30,this->height() - 50, this->width(),50 ));
    label->setAttribute(Qt::WA_TransparentForMouseEvents);

    //当前步数
    QLabel * plabel = new QLabel;
    plabel->setParent(this);
    QFont pfont;
    pfont.setFamily("华文新魏");
    pfont.setPointSize(20);
    plabel->setFont(pfont);
    QString pstr = QString("pace: %1").arg(this->pace);
    plabel->setText(pstr);
    plabel->setGeometry(QRect(30,this->height() - 100, this->width(),50 ));
    plabel->setAttribute(Qt::WA_TransparentForMouseEvents);

    //胜利图片
    QLabel * winLabel = new QLabel;
    winLabel->setParent(this);
    QPixmap pix;
    pix.load(":/res/xbdnhny.png");
    winLabel->setPixmap(pix);
    winLabel->setGeometry(0,0,pix.width(),pix.height());
    winLabel->move(this->width()*0.5-pix.width()*0.5,-pix.height());
    QPropertyAnimation *animation = new QPropertyAnimation(winLabel,"geometry");


    //初始化二维数组
    int array21[19][19];
    srand((unsigned)time(NULL));
    for(int i=0;i<19;i++)
    {
        for(int j=0;j<19;j++)
        {
            array21[i][j] = (rand() % 2);
            //array21[i][j]=1;
            //if(i==18&&j==18) array21[i][j]=0;
        }
    }
    for(int i=0;i<19;i++){
        for(int j=0;j<19;j++){
            this->gameArray[i][j] = array21[i][j];
        }
    }

    //创建金币的背景图片
    for(int i = 0 ; i < 19;i++)
    {
        for(int j = 0 ; j < 19; j++)
           {
            //绘制背景图片
            QLabel* label = new QLabel;
            QPixmap pix;
            pix.load(":/res/BoardNode(1).png");
            label->setGeometry(0,0,pix.width(),pix.height());
            label->setPixmap(pix);
            label->setParent(this);
            label->move(35 + i*50,40+j*50);

            //创建金币
            QString str;
            if(this->gameArray[i][j] == 1){
                str = ":/res/Coin0001.png";
            }
            else
            {
                str = ":/res/Coin0008.png";
            }
            MyCoin * coin = new MyCoin(str);
            coin->setParent(this);
            coin->move(35 + i*50,40+j*50);
            coin->posX=i;
            coin->posY=j;
            coin->flag = gameArray[i][j];
            this->coinBtn[i][j]=coin;
            //点击硬币调用
            connect(coin,&MyCoin::clicked,[=](){

                if(current==0)
                {
                    coin->changeFlag();

                    //刷新步数显示
                    pace++;
                    QString pstr = QString("pace: %1").arg(this->pace);
                    plabel->setText(pstr);
                    plabel->setGeometry(QRect(30,this->height() - 100, this->width(),50 ));
                    plabel->setAttribute(Qt::WA_TransparentForMouseEvents);


                    //同步二维数组，方便后期扩展
                    gameArray[i][j]=gameArray[i][j]==0?1:0;

                    //翻转周围硬币
                    QTimer::singleShot(300,this,[=](){
                        //右侧
                        if(coin->posX+1<=18)
                        {
                            this->coinBtn[coin->posX+1][coin->posY]->changeFlag();
                            gameArray[coin->posX+1][coin->posY] = gameArray[coin->posX+1][coin->posY]==0?1:0;
                        }
                        //左侧
                        if(coin->posX-1>=0)
                        {
                            this->coinBtn[coin->posX-1][coin->posY]->changeFlag();
                            gameArray[coin->posX-1][coin->posY] = gameArray[coin->posX-1][coin->posY]==0?1:0;
                        }
                        //下侧
                        if(coin->posY+1<=18)
                        {
                            this->coinBtn[coin->posX][coin->posY+1]->changeFlag();
                            gameArray[coin->posX][coin->posY+1] = gameArray[coin->posX][coin->posY+1]==0?1:0;
                        }
                        //上侧
                        if(coin->posY-1>=0)
                        {
                            this->coinBtn[coin->posX][coin->posY-1]->changeFlag();
                            gameArray[coin->posX][coin->posY-1] = gameArray[coin->posX][coin->posY-1]==0?1:0;
                        }

                        //检测游戏是否胜利
                        this->isWin = true;
                        for(int i=0;i<19;i++)
                        {
                            for(int j=0;j<19;j++)
                            {
                                if(this->coinBtn[i][j]->flag==false)
                                {
                                    this->isWin=false;
                                    break;
                                }
                            }

                        }

                        if(this->isWin)
                        {
                            animation->setDuration(1000);
                            animation->setStartValue(QRect(winLabel->x(),winLabel->y(),winLabel->width(),winLabel->height()));
                            animation->setEndValue(QRect(winLabel->x(),winLabel->y()+814,winLabel->width(),winLabel->height()));
                            animation->setEasingCurve(QEasingCurve::OutBounce);
                            animation->start(QAbstractAnimation::DeleteWhenStopped);

                            if(pace<=50)
                            {
                                QMessageBox msgbox;
                                msgbox.setText("您被封为：咸鱼（翻深）之王");
                                msgbox.exec();
                            }
                            else if(pace>50&&pace<150)
                            {
                                QMessageBox msgbox;
                                msgbox.setText("您被封为：咸鱼（翻深）宝宝");
                                msgbox.exec();
                            }
                            else
                            {
                                QMessageBox msgbox;
                                msgbox.setText("咸鱼，你的功力还不足噢！");
                                msgbox.exec();
                            }

                            for(int i=0;i<19;i++)
                            {
                                for(int j=0;j<19;j++)
                                {
                                    this->coinBtn[i][j]->isWin=true;
                                }
                            }
                        }
                        else
                        {
                            for(int i=0;i<19;i++)
                            {
                                for(int j=0;j<19;j++)
                                {
                                    this->coinBtn[i][j]->isWin = false;
                                }
                            }
                        }
                    });
                }
                if(current==1)
                {
                    coin->changeFlag();

                    //使用次数
                    QString mstr1 = QString("使用次数: %1").arg(++i1);
                    mlabel1->setText(mstr1);
                    mlabel1->setGeometry(QRect(this->width() - chick1->width()-100,this->height() - chick1->height(), this->width(),50 ));
                    mlabel1->setAttribute(Qt::WA_TransparentForMouseEvents);

                    //刷新步数显示
                    //plabel->update();
                    pace++;
                    QString pstr = QString("pace: %1").arg(this->pace);
                    plabel->setText(pstr);
                    plabel->setGeometry(QRect(30,this->height() - 100, this->width(),50 ));
                    plabel->setAttribute(Qt::WA_TransparentForMouseEvents);

                    //刷新money显示

                    money = money-10;
                    QString mstr = QString("money: %1").arg(this->money);
                    mlabel->setText(mstr);
                    mlabel->setGeometry(QRect(700,this->height() - 100, this->width(),50 ));
                    mlabel->setAttribute(Qt::WA_TransparentForMouseEvents);

                    //同步二维数组，方便后期扩展
                    gameArray[i][j]=gameArray[i][j]==0?1:0;

                    //翻转一个硬币
                    QTimer::singleShot(300,this,[=](){
                        //检测游戏是否胜利
                        this->isWin = true;
                        for(int i=0;i<19;i++)
                        {
                            for(int j=0;j<19;j++)
                            {
                                if(this->coinBtn[i][j]->flag==false)
                                {
                                    this->isWin=false;
                                    break;
                                }
                            }
                        }

                        if(this->isWin)
                        {
                            QPropertyAnimation *animation = new QPropertyAnimation(winLabel,"geometry");
                            animation->setDuration(1000);
                            animation->setStartValue(QRect(winLabel->x(),winLabel->y(),winLabel->width(),winLabel->height()));
                            animation->setEndValue(QRect(winLabel->x(),winLabel->y()+814,winLabel->width(),winLabel->height()));
                            animation->setEasingCurve(QEasingCurve::OutBounce);
                            animation->start(QAbstractAnimation::DeleteWhenStopped);

                            if(pace<=50)
                            {
                                QMessageBox msgbox;
                                msgbox.setText("您被封为：咸鱼（翻深）之王");
                                msgbox.exec();
                            }
                            else if(pace>50&&pace<150)
                            {
                                QMessageBox msgbox;
                                msgbox.setText("您被封为：咸鱼（翻深）宝宝");
                                msgbox.exec();
                            }
                            else
                            {
                                QMessageBox msgbox;
                                msgbox.setText("咸鱼，你的功力还不足噢！");
                                msgbox.exec();
                            }

                            for(int i=0;i<19;i++)
                            {
                                for(int j=0;j<19;j++)
                                {
                                    this->coinBtn[i][j]->isWin=true;
                                }
                            }
                        }
                        else
                        {
                            for(int i=0;i<19;i++)
                            {
                                for(int j=0;j<19;j++)
                                {
                                    this->coinBtn[i][j]->isWin = false;
                                }
                            }
                        }
                    });
                    current = 0;
                }

                if(current==2)
                {
                    coin->changeFlag();

                    //使用次数
                    QString mstr2 = QString("使用次数: %1").arg(++i2);
                    mlabel2->setText(mstr2);
                    mlabel2->setGeometry(QRect(this->width() - chick2->width()-200,this->height() - chick2->height(), this->width(),50 ));
                    mlabel2->setAttribute(Qt::WA_TransparentForMouseEvents);


                    //刷新步数显示
                    pace++;
                    QString pstr = QString("pace: %1").arg(this->pace);
                    plabel->setText(pstr);
                    plabel->setGeometry(QRect(30,this->height() - 100, this->width(),50 ));
                    plabel->setAttribute(Qt::WA_TransparentForMouseEvents);

                    //刷新money显示
                    money = money-10;
                    QString mstr = QString("money: %1").arg(this->money);
                    mlabel->setText(mstr);
                    mlabel->setGeometry(QRect(700,this->height() - 100, this->width(),50 ));
                    mlabel->setAttribute(Qt::WA_TransparentForMouseEvents);

                    //同步二维数组，方便后期扩展
                    gameArray[i][j]=gameArray[i][j]==0?1:0;

                    //翻转一整行一整列硬币
                    QTimer::singleShot(300,this,[=](){
                        //行
                        for(int i=0;i<19;i++)
                        {
                            this->coinBtn[i][coin->posY]->changeFlag();
                            gameArray[i][coin->posY] = gameArray[i][coin->posY]==0?1:0;
                        }
                        //列
                        for(int i=0;i<19;i++)
                        {
                            this->coinBtn[coin->posX][i]->changeFlag();
                            gameArray[coin->posX][i] = gameArray[coin->posX][i]==0?1:0;
                        }
                        //检测游戏是否胜利
                        this->isWin = true;
                        for(int i=0;i<19;i++)
                        {
                            for(int j=0;j<19;j++)
                            {
                                if(this->coinBtn[i][j]->flag==false)
                                {
                                    this->isWin=false;
                                    break;
                                }
                            }
                        }

                        if(this->isWin)
                        {
                            QPropertyAnimation *animation = new QPropertyAnimation(winLabel,"geometry");
                            animation->setDuration(1000);
                            animation->setStartValue(QRect(winLabel->x(),winLabel->y(),winLabel->width(),winLabel->height()));
                            animation->setEndValue(QRect(winLabel->x(),winLabel->y()+814,winLabel->width(),winLabel->height()));
                            animation->setEasingCurve(QEasingCurve::OutBounce);
                            animation->start(QAbstractAnimation::DeleteWhenStopped);

                            if(pace<=50)
                            {
                                QMessageBox msgbox;
                                msgbox.setText("您被封为：咸鱼（翻深）之王");
                                msgbox.exec();
                            }
                            else if(pace>50&&pace<150)
                            {
                                QMessageBox msgbox;
                                msgbox.setText("您被封为：咸鱼（翻深）宝宝");
                                msgbox.exec();
                            }
                            else
                            {
                                QMessageBox msgbox;
                                msgbox.setText("咸鱼，你的功力还不足噢！");
                                msgbox.exec();
                            }


                            for(int i=0;i<19;i++)
                            {
                                for(int j=0;j<19;j++)
                                {
                                    this->coinBtn[i][j]->isWin=true;
                                }
                            }
                        }
                        else
                        {
                            for(int i=0;i<19;i++)
                            {
                                for(int j=0;j<19;j++)
                                {
                                    this->coinBtn[i][j]->isWin = false;
                                }
                            }
                        }
                    });
                    current = 0;
                }

                if(current==3)
                {
                    if(coin->flag==0)
                    {
                        coin->changeFlag();

                        //使用次数
                        QString mstr3 = QString("使用次数: %1").arg(++i3);
                        mlabel3->setText(mstr3);
                        mlabel3->setGeometry(QRect(this->width() - chick3->width()-300,this->height() - chick3->height(), this->width(),50 ));
                        mlabel3->setAttribute(Qt::WA_TransparentForMouseEvents);


                        //刷新步数显示
                        //plabel->update();
                        pace++;
                        QString pstr = QString("pace: %1").arg(this->pace);
                        plabel->setText(pstr);
                        plabel->setGeometry(QRect(30,this->height() - 100, this->width(),50 ));
                        plabel->setAttribute(Qt::WA_TransparentForMouseEvents);

                        //刷新money显示
                        money = money-10;
                        QString mstr = QString("money: %1").arg(this->money);
                        mlabel->setText(mstr);
                        mlabel->setGeometry(QRect(700,this->height() - 100, this->width(),50 ));
                        mlabel->setAttribute(Qt::WA_TransparentForMouseEvents);

                        //同步二维数组，方便后期扩展
                        gameArray[i][j]=gameArray[i][j]==0?1:0;
                    }

                    //只翻金不翻银
                    QTimer::singleShot(300,this,[=](){
                        //右侧
                        if(coin->posX+1<=18)
                        {

                            if(coinBtn[coin->posX+1][coin->posY]->flag==false)
                            {
                                this->coinBtn[coin->posX+1][coin->posY]->changeFlag();
                                gameArray[coin->posX+1][coin->posY] = gameArray[coin->posX+1][coin->posY]==0?1:0;
                            }
                        }
                        //左侧
                        if(coin->posX-1>=0)
                        {
                            if(coinBtn[coin->posX-1][coin->posY]->flag==false)
                            {
                                this->coinBtn[coin->posX-1][coin->posY]->changeFlag();
                                gameArray[coin->posX-1][coin->posY] = gameArray[coin->posX-1][coin->posY]==0?1:0;
                            }
                        }
                        //下侧
                        if(coin->posY+1<=18)
                        {
                            if(coinBtn[coin->posX][coin->posY+1]->flag==false)
                            {
                                this->coinBtn[coin->posX][coin->posY+1]->changeFlag();
                                gameArray[coin->posX][coin->posY+1] = gameArray[coin->posX][coin->posY+1]==0?1:0;
                            }
                        }
                        //上侧
                        if(coin->posY-1>=0)
                        {
                            if(coinBtn[coin->posX][coin->posY-1]->flag==false)
                            {
                                this->coinBtn[coin->posX][coin->posY-1]->changeFlag();
                                gameArray[coin->posX][coin->posY-1] = gameArray[coin->posX][coin->posY-1]==0?1:0;
                            }
                        }
                        //检测游戏是否胜利
                        this->isWin = true;
                        for(int i=0;i<19;i++)
                        {
                            for(int j=0;j<19;j++)
                            {
                                if(this->coinBtn[i][j]->flag==false)
                                {
                                    this->isWin=false;
                                    break;
                                }
                            }
                        }

                        if(this->isWin)
                        {
                            QPropertyAnimation *animation = new QPropertyAnimation(winLabel,"geometry");
                            animation->setDuration(1000);
                            animation->setStartValue(QRect(winLabel->x(),winLabel->y(),winLabel->width(),winLabel->height()));
                            animation->setEndValue(QRect(winLabel->x(),winLabel->y()+814,winLabel->width(),winLabel->height()));
                            animation->setEasingCurve(QEasingCurve::OutBounce);
                            animation->start(QAbstractAnimation::DeleteWhenStopped);

                            if(pace<=50)
                            {
                                QMessageBox msgbox;
                                msgbox.setText("您被封为：咸鱼（翻深）之王");
                                msgbox.exec();
                            }
                            else if(pace>50&&pace<150)
                            {
                                QMessageBox msgbox;
                                msgbox.setText("您被封为：咸鱼（翻深）宝宝");
                                msgbox.exec();
                            }
                            else
                            {
                                QMessageBox msgbox;
                                msgbox.setText("咸鱼，你的功力还不足噢！");
                                msgbox.exec();
                            }

                            for(int i=0;i<19;i++)
                            {
                                for(int j=0;j<19;j++)
                                {
                                    this->coinBtn[i][j]->isWin=true;
                                }
                            }
                        }
                        else
                        {
                            for(int i=0;i<19;i++)
                            {
                                for(int j=0;j<19;j++)
                                {
                                    this->coinBtn[i][j]->isWin = false;
                                }
                            }
                        }
                    });
                    current = 0;
                }

                if(current==4)
                {
                    coin->changeFlag();

                    //使用次数
                    QString mstr4 = QString("使用次数: %1").arg(++i4);
                    mlabel4->setText(mstr4);
                    mlabel4->setGeometry(QRect(this->width() - chick4->width()-400,this->height() - chick4->height(), this->width(),50 ));
                    mlabel4->setAttribute(Qt::WA_TransparentForMouseEvents);


                    //刷新步数显示
                    pace++;
                    QString pstr = QString("pace: %1").arg(this->pace);
                    plabel->setText(pstr);
                    plabel->setGeometry(QRect(30,this->height() - 100, this->width(),50 ));
                    plabel->setAttribute(Qt::WA_TransparentForMouseEvents);

                    //刷新money显示
                    money = money-10;
                    QString mstr = QString("money: %1").arg(this->money);
                    mlabel->setText(mstr);
                    mlabel->setGeometry(QRect(700,this->height() - 100, this->width(),50 ));
                    mlabel->setAttribute(Qt::WA_TransparentForMouseEvents);

                    //同步二维数组，方便后期扩展
                    gameArray[i][j]=gameArray[i][j]==0?1:0;

                    //翻转对角硬币
                    QTimer::singleShot(300,this,[=](){
                        //右上侧
                        if(coin->posX+1<=18&&coin->posY-1>=0)
                        {
                            this->coinBtn[coin->posX+1][coin->posY-1]->changeFlag();
                            gameArray[coin->posX+1][coin->posY-1] = gameArray[coin->posX+1][coin->posY-1]==0?1:0;
                        }
                        //左上侧
                        if(coin->posX-1>=0&&coin->posY-1>=0)
                        {
                            this->coinBtn[coin->posX-1][coin->posY-1]->changeFlag();
                            gameArray[coin->posX-1][coin->posY-1] = gameArray[coin->posX-1][coin->posY-1]==0?1:0;
                        }
                        //左下侧
                        if(coin->posX-1>=0&&coin->posY+1<=18)
                        {
                            this->coinBtn[coin->posX-1][coin->posY+1]->changeFlag();
                            gameArray[coin->posX-1][coin->posY+1] = gameArray[coin->posX-1][coin->posY+1]==0?1:0;
                        }
                        //右下侧
                        if(coin->posX+1<=18&&coin->posY+1<=18)
                        {
                            this->coinBtn[coin->posX+1][coin->posY+1]->changeFlag();
                            gameArray[coin->posX+1][coin->posY+1] = gameArray[coin->posX+1][coin->posY+1]==0?1:0;
                        }

                        //检测游戏是否胜利
                        this->isWin = true;
                        for(int i=0;i<19;i++)
                        {
                            for(int j=0;j<19;j++)
                            {
                                if(this->coinBtn[i][j]->flag==false)
                                {
                                    this->isWin=false;
                                    break;
                                }
                            }
                        }

                        if(this->isWin)
                        {
                            animation->setDuration(1000);
                            animation->setStartValue(QRect(winLabel->x(),winLabel->y(),winLabel->width(),winLabel->height()));
                            animation->setEndValue(QRect(winLabel->x(),winLabel->y()+814,winLabel->width(),winLabel->height()));
                            animation->setEasingCurve(QEasingCurve::OutBounce);
                            animation->start(QAbstractAnimation::DeleteWhenStopped);

                            for(int i=0;i<19;i++)
                            {
                                for(int j=0;j<19;j++)
                                {
                                    this->coinBtn[i][j]->isWin=true;
                                }
                            }
                        }
                        else
                        {
                            for(int i=0;i<19;i++)
                            {
                                for(int j=0;j<19;j++)
                                {
                                    this->coinBtn[i][j]->isWin = false;
                                }
                            }
                        }
                    });
                    current = 0;
                }
            });

        }
    }

}
//绘图事件
void BossPlay::paintEvent(QPaintEvent *){
    QPainter painter(this);
    QPixmap pix;
    pix.load(":/res/bfda0be809541c57e1407952d1e6042.jpg");
    painter.drawPixmap(0,0,this->width(),this->height(),pix);

    //标题
    pix.load(":/res/Title.png");
    painter.drawPixmap((this->width()-pix.width())*0.5,30,pix);
}
